<?php
namespace app\admin\controller;

use app\common\entity\BackResult;
use app\common\service\RecommendService;
use app\Request;

/**
 * 首页推荐的页面只能看列表 和取消 相关的推荐操作在 专栏和视频页操作
 * Class Recommend
 * @package app\admin\controller
 */
class Recommend extends Base
{

    /**
     * 首页推荐
     * @param Request $request
     * @return \think\Response
     */
    public function index(Request $request)
    {
        $page = $request->param('page', 1);
        $pageSize = $request->param('pageSize', 10);
        $searchField = $request->param('search_field', '');
        $searchValue = $request->param('search_value', '');
        $status = $request->param('status', 0);
        $type = $request->param('type', 1);
        $service = new RecommendService();
        $result = $service->recommendList($page, $pageSize, $searchField, $searchValue, $status, $type);
        return BackResult::success($result);
    }


    public function create(Request $request)
    {
        $data = $request->post();
        $service = new RecommendService();
        $data['create_time'] = time();
        $data['update_time'] = time();
        $result = $service->create($data);
        return BackResult::success($result);
    }


    public function remove(Request $request){
        $id = $request->param('id');
        $service = new RecommendService();
        $service->remove($id);
        return BackResult::success();
    }

}